package com.zhongkun.datahome.service.constant;

import lombok.Getter;

import java.util.Objects;

/**
 * @Author: lifengsheng
 * @Date: 2025/4/15 15:51
 * @Desc
 */
@Getter
public enum SwitchEnum {
    ON(1, "开"),
    OFF(0, "关");

    private Integer status;

    private String desc;

    SwitchEnum(Integer status, String desc) {
        this.status = status;
        this.desc = desc;
    }

    public static boolean isValid(Integer status) {
        for (SwitchEnum value : SwitchEnum.values()) {
            if (value.getStatus().equals(status)) {
                return true;
            }
        }
        return false;
    }

    public boolean is(Integer status) {
        return Objects.equals(this.status, status);
    }

    public static Integer getStatus(Integer status) {
        return SwitchEnum.ON.is(status) ? SwitchEnum.ON.getStatus() : SwitchEnum.OFF.getStatus();
    }
}
